package team.freeroom.hotelmanage.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import team.freeroom.hotelmanage.repository.entity.User;
import team.freeroom.hotelmanage.repository.mapper.UserMapper;
import team.freeroom.hotelmanage.service.UserService;
import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByUsername(String username) {
        return userMapper.findByUsername(username);
    }

    @Override
    public int add(User user) {
        return userMapper.add(user);
    }

    @Override
    public int edit(User user) {
        return userMapper.edit(user);
    }

    @Override
    public int delete(String ids) {
        return userMapper.delete(ids);
    }

    @Override
    public List<User> findList(Map<String, Object> queryMap) {
        return userMapper.findList(queryMap);
    }

    @Override
    public int getTotal(Map<String, Object> queryMap) {
        return userMapper.getTotal(queryMap);
    }

    @Override
    public int editPassword(User user) {
        return userMapper.editPassword(user);
    }

    @Override
    public boolean isExist(String username,Long id) {
        User user = findByUsername(username);
        if(user == null)return false;
        if(user.getId().longValue() == id.longValue())return false;
        return true;
    }
}
